package com.lww.feature.test.memory;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.junit.Test;

import javax.jms.Session;
import javax.lang.model.element.VariableElement;
import javax.xml.crypto.Data;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

/**
 * User: yian
 * Date: 2018/11/5
 */
public class CapacityAssessment {


    //static 对象不在堆里
   public static ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap<String, Object>();


    @Test
    public void testConcurrentHashMap() throws InterruptedException {
        ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap<String, Object>();
        System.out.println("start put");
        for(int i= 0;i<100000;i++) {
            concurrentHashMap.put(UUID.randomUUID().toString(),new UserInfo(UUID.randomUUID().toString(),new Date()));
        }
        System.out.println("put end,size:"+concurrentHashMap.size());
        Thread.sleep(10000000);
        System.out.println(concurrentHashMap.size());
    }


    @Getter
    @Setter
    @NoArgsConstructor
    @AllArgsConstructor
    public static class UserInfo {
        private String code;
        private Date exprieDate;


    }


}
